/**
 * Copyright 2004 - 2007 Blue Bamboo International Inc. 
 *           All rights reserved.
 *
 *
 * Blue Bamboo PROPRIETARY/CONFIDENTIAL.
 *
 */

package com.bluebamboo.bta.codec;

import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;

/**
 * DOCME
 * 
 * @author Nick.Tan
 * 
 */
public class MyProtocolDecoder extends CumulativeProtocolDecoder {

	@Override
	protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception {
		ByteBuffer bufferOut = ByteBuffer.allocate(in.limit()).setAutoExpand(true);
		while (in.hasRemaining()) {
			bufferOut.put(in.get());
			bufferOut.put((byte) '|');
		}
		out.write(bufferOut);
		return false;
	}

}
